package cn.itsource.ymcc.client;

import cn.itsource.ymcc.doc.CourseDoc;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SearchClientFallbackFactory implements FallbackFactory<SearchClient> {
    @Override
    public SearchClient create(Throwable throwable) {
        return new SearchClient() {
            @Override
            public JsonResult saveBatch(List<CourseDoc> courseDocs) {
                throwable.printStackTrace();
                return JsonResult.error("全文检索服务 saveBatch 接口调用失败！" + throwable.getMessage());
            }

            @Override
            public JsonResult deleteBatch(List<Long> courseIds) {
                throwable.printStackTrace();
                return JsonResult.error("全文检索服务 deleteBatch 接口调用失败！" + throwable.getMessage());
            }
        };
    }
}
